// 我的博客
function showaddblog() {
    var target = document.getElementById("writeblog");
    target.style.display = "block";
    var short = document.getElementById("blogboard");
    short.style.height = "258.4px";
}
function hideaddblogfuc() {
    var targetoff = document.getElementById("writeblog");
    targetoff.style.display = "none";
    var long = document.getElementById("blogboard");
    long.style.height = "558.4px";
}
function addblog() {
    var title = document.getElementById("blogtitle").value;
    var content = document.getElementById("blog").value;
    var blogger = document.getElementById("blogger").value;
    var print = document.getElementById("blogboard");
    var newli = document.createElement("li");
    var newh3 = document.createElement("h3");
    var newp1 = document.createElement("p");
    var newp2 = document.createElement("p");
    var newp3 = document.createElement("p");
    var newbtn = document.createElement("input");
    newbtn.id = "deleteblog";
    newbtn.type = "button";
    newbtn.value = "删除";
    newbtn.style.float = "right";
    newbtn.addEventListener("click", deleteblog);
    function deleteblog() {
        var target = document.getElementById("blogboard");
        if (target.hasChildNodes) {
            target.removeChild(newli);
        }
    }
    var d = new Date();
    var year = d.getFullYear();
    var month = d.getMonth() + 1;
    var day = d.getDate();
    var hour = d.getHours();
    var minute = d.getMinutes();
    var second = d.getSeconds();
    var txt1 = document.createTextNode(title);
    var txt2 = document.createTextNode(content);
    var txt3 = document.createTextNode(blogger);
    var txt4 = document.createTextNode(year + "/" + month + "/" + day + " " + hour + ":" + minute + ":" + second);
    newh3.appendChild(txt1);
    newp1.appendChild(txt2);
    newp2.appendChild(txt3);
    newp3.appendChild(txt4);
    print.appendChild(newli);
    newli.appendChild(newh3);
    newli.appendChild(newp1);
    newli.appendChild(newp2);
    newli.appendChild(newbtn);
    newli.appendChild(newp3);
}

// 留言板块
function addmessage() {
    var content = document.getElementById("message").value;
    var print = document.getElementById("messageboard");
    var newli = document.createElement("li");
    var newp1 = document.createElement("p");
    var newp2 = document.createElement("p");
    var newbtn = document.createElement("input");
    newbtn.id = "deletemessage";
    newbtn.type = "button";
    newbtn.value = "删除";
    newbtn.style.float = "right";
    newbtn.addEventListener("click", deletemessage);
    function deletemessage() {
        var target = document.getElementById("messageboard");
        if (target.hasChildNodes) {
            target.removeChild(newli);
        }
    }
    var d = new Date();
    var year = d.getFullYear();
    var month = d.getMonth() + 1;
    var day = d.getDate();
    var hour = d.getHours();
    var minute = d.getMinutes();
    var second = d.getSeconds();
    var txt1 = document.createTextNode(content);
    var txt2 = document.createTextNode(year + "/" + month + "/" + day + " " + hour + ":" + minute + ":" + second);
    newp1.appendChild(txt1);
    newp2.appendChild(txt2);
    print.appendChild(newli);
    newli.appendChild(newp1);
    newli.appendChild(newbtn);
    newli.appendChild(newp2);
}